<?php
Class Users_model extends CI_Model {

  //Search the user into the database in order to do login
  function login($username, $password, $country) {
    $password = md5($password);
    $sql = "Login_User '$username', '$password', '$country'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  //Saves an user into the database
  function save($username, $nickname, $password, $usertype, $country, $userdorp, $userstate) {
    $password = md5($password);
	   $sql = "Save_User '$username', '$nickname', '$password', '$usertype', '$country', '$userdorp', '$userstate'"; 
    $query = $this->db->query($sql);
    return $query->num_rows();
  }

  function gettypeusers() {
    $sql = "SELECT id_tipousuario, ds_tipousuario FROM TipoUsuarios";
    $query = $this->db->query($sql);
    return $query->result();
  }

  function getallusers() {
    $sql = "SELECT id_usuario, ds_usuario FROM Usuarios";
    $query = $this->db->query($sql);
    return $query->result();
  }

  function getuserbyid($id) {
    $sql = "Search_User '$id'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  
}
?>